package com.photoeditor.demo.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

import com.photoeditor.demo.util.DisplayUtils;

/**
 * Created by winn on 17/1/22.
 */

public class DialogScrollView extends ScrollView {

    public DialogScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DialogScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        try {
            //最大高度显示为屏幕内容高度的一半
            int screenH = DisplayUtils.SCREEN_HEIGHT;
            heightMeasureSpec = MeasureSpec.makeMeasureSpec(screenH / 2, MeasureSpec.AT_MOST);
        } catch (Exception e) {
            e.printStackTrace();
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}